package com.czk.domain;

/**
 * 消息结果的构建
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/29 10:50
 */
public class EasyResult {
    private boolean success;
    private String msg;
    private String title;

    /**
     * 构建成功消息
     *
     * @return
     */
    static public EasyResult buildSuccessResult() {
        EasyResult result = new EasyResult();
        result.setMsg("ok");
        result.setSuccess(true);
        return result;
    }

    /**
     * 构建失败消息
     *
     * @param e
     * @return
     */
    static public EasyResult buildErrResult(Exception e) {
        EasyResult easyResult = new EasyResult();
        easyResult.setSuccess(false);
        easyResult.setMsg(e.getMessage());
        return easyResult;
    }

    static public EasyResult buildErrResult(String msg) {
        EasyResult easyResult = new EasyResult();
        easyResult.setSuccess(false);
        easyResult.setMsg(msg);
        return easyResult;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
